<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>易达设备用电接口文档</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            max-width: 1000px;
            margin: 0 auto;
            padding: 20px;
        }
        h1, h2, h3 {
            color: #2c3e50;
            margin-top: 30px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 15px 0;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
        }
        pre {
            background-color: #f5f5f5;
            padding: 10px;
            border-radius: 5px;
            overflow-x: auto;
        }
        .code-block {
            background-color: #f5f5f5;
            padding: 10px;
            border-radius: 5px;
            font-family: Consolas, monospace;
        }
        .section {
            margin-bottom: 30px;
        }
    </style>
</head>
<body>
    <h1>易达设备用电接口文档</h1>
    
    <div class="section">
        <h2>1. 基本信息</h2>
        <table>
            <tr>
                <th>项目</th>
                <th>说明</th>
            </tr>
            <tr>
                <td>服务器地址</td>
                <td>172.168.13.13:8030</td>
            </tr>
            <tr>
                <td>基础路径</td>
                <td>/api/ydMeterData</td>
            </tr>
            <tr>
                <td>认证方式</td>
                <td>Bearer Token (JWT)</td>
            </tr>
            <tr>
                <td>日期格式</td>
                <td>yyyy-MM-dd 或 yyyy-MM-dd HH:mm:ss</td>
            </tr>
        </table>
    </div>

    <div class="section">
        <h2>2. 接口列表</h2>
        
        <h3>2.1 认证接口</h3>
        
        <h4>2.1.1 获取访问令牌</h4>
        <table>
            <tr>
                <th>项目</th>
                <th>说明</th>
            </tr>
            <tr>
                <td>接口URL</td>
                <td>/api/auth/login</td>
            </tr>
            <tr>
                <td>请求方式</td>
                <td>POST</td>
            </tr>
            <tr>
                <td>Content-Type</td>
                <td>application/json</td>
            </tr>
        </table>

        <h4>请求参数</h4>
        <table>
            <tr>
                <th>参数名</th>
                <th>类型</th>
                <th>是否必须</th>
                <th>描述</th>
                <th>示例值</th>
            </tr>
            <tr>
                <td>username</td>
                <td>String</td>
                <td>是</td>
                <td>用户名</td>
                <td>"your_username"</td>
            </tr>
            <tr>
                <td>password</td>
                <td>String</td>
                <td>是</td>
                <td>密码</td>
                <td>"your_password"</td>
            </tr>
        </table>

        <h4>响应参数</h4>
        <table>
            <tr>
                <th>参数名</th>
                <th>类型</th>
                <th>描述</th>
            </tr>
            <tr>
                <td>code</td>
                <td>Integer</td>
                <td>状态码</td>
            </tr>
            <tr>
                <td>msg</td>
                <td>String</td>
                <td>响应消息</td>
            </tr>
            <tr>
                <td>data</td>
                <td>Object</td>
                <td>响应数据</td>
            </tr>
        </table>

        <h5>data对象结构</h5>
        <table>
            <tr>
                <th>参数名</th>
                <th>类型</th>
                <th>描述</th>
            </tr>
            <tr>
                <td>userInfo</td>
                <td>Object</td>
                <td>用户信息</td>
            </tr>
            <tr>
                <td>tokenInfo</td>
                <td>Object</td>
                <td>令牌信息</td>
            </tr>
        </table>

        <h5>tokenInfo对象结构</h5>
        <table>
            <tr>
                <th>参数名</th>
                <th>类型</th>
                <th>描述</th>
            </tr>
            <tr>
                <td>accessToken</td>
                <td>String</td>
                <td>访问令牌</td>
            </tr>
            <tr>
                <td>tokenType</td>
                <td>String</td>
                <td>令牌类型</td>
            </tr>
            <tr>
                <td>expiresIn</td>
                <td>Integer</td>
                <td>访问令牌有效期（秒）</td>
            </tr>
            <tr>
                <td>refreshToken</td>
                <td>String</td>
                <td>刷新令牌</td>
            </tr>
            <tr>
                <td>refreshExpiresIn</td>
                <td>Integer</td>
                <td>刷新令牌有效期（秒）</td>
            </tr>
        </table>

        <h4>响应示例</h4>
        <div class="code-block">
{
  "msg": "登录成功",
  "code": 0,
  "data": {
    "userInfo": {
      "createTime": "2025-08-24 04:14:53",
      "nickName": "数据上传账号",
      "sex": "0",
      "phonenumber": "",
      "deptId": 202,
      "avatar": "",
      "userId": 102,
      "email": "",
      "username": "yd999",
      "status": "0"
    },
    "tokenInfo": {
      "expiresIn": 86400,
      "accessToken": "eyJhbGciOiJIUz......",
      "tokenType": "Bearer",
      "refreshToken": "eyJhbGciOiIUK......",
      "refreshExpiresIn": 604800
    }
  }
}
        </div>

        <h4>2.1.2 刷新令牌</h4>
        <table>
            <tr>
                <th>项目</th>
                <th>说明</th>
            </tr>
            <tr>
                <td>接口URL</td>
                <td>/api/auth/refresh</td>
            </tr>
            <tr>
                <td>请求方式</td>
                <td>POST</td>
            </tr>
            <tr>
                <td>Content-Type</td>
                <td>application/json</td>
            </tr>
        </table>

        <h4>请求参数</h4>
        <table>
            <tr>
                <th>参数名</th>
                <th>类型</th>
                <th>是否必须</th>
                <th>描述</th>
                <th>示例值</th>
            </tr>
            <tr>
                <td>refreshToken</td>
                <td>String</td>
                <td>是</td>
                <td>刷新令牌</td>
                <td>"your_refresh_token"</td>
            </tr>
        </table>

        <h3>2.2 数据查询接口</h3>
        <table>
            <tr>
                <th>项目</th>
                <th>说明</th>
            </tr>
            <tr>
                <td>接口URL</td>
                <td>/api/ydMeterData/queryList</td>
            </tr>
            <tr>
                <td>请求方式</td>
                <td>GET</td>
            </tr>
            <tr>
                <td>请求头</td>
                <td>
                    <div class="code-block">
                        Authorization: Bearer &lt;your_jwt_token&gt;
                    </div>
                </td>
            </tr>
        </table>

        <h4>查询参数（Query String）</h4>
        <table>
            <tr>
                <th>参数名</th>
                <th>类型</th>
                <th>是否必须</th>
                <th>描述</th>
                <th>示例值</th>
            </tr>
            <tr>
                <td>furnaceNo</td>
                <td>Integer</td>
                <td>否</td>
                <td>炉号（与日期范围至少提供一项）</td>
                <td>1</td>
            </tr>
            <tr>
                <td>startDate</td>
                <td>String</td>
                <td>否</td>
                <td>开始日期（格式：yyyy-MM-dd，自动补时间00:00:00）</td>
                <td>"2024-05-01"</td>
            </tr>
            <tr>
                <td>endDate</td>
                <td>String</td>
                <td>否</td>
                <td>结束日期（格式：yyyy-MM-dd，自动补时间23:59:59）</td>
                <td>"2024-05-20"</td>
            </tr>
            <tr>
                <td>pageNum</td>
                <td>Integer</td>
                <td>是</td>
                <td>当前页码（从1开始）</td>
                <td>1</td>
            </tr>
            <tr>
                <td>pageSize</td>
                <td>Integer</td>
                <td>是</td>
                <td>每页记录数</td>
                <td>10</td>
            </tr>
        </table>

        <h4>响应参数</h4>
        <table>
            <tr>
                <th>参数名</th>
                <th>类型</th>
                <th>描述</th>
            </tr>
            <tr>
                <td>code</td>
                <td>Integer</td>
                <td>状态码</td>
            </tr>
            <tr>
                <td>msg</td>
                <td>String</td>
                <td>响应消息</td>
            </tr>
            <tr>
                <td>total</td>
                <td>Integer</td>
                <td>总记录数</td>
            </tr>
            <tr>
                <td>rows</td>
                <td>Array</td>
                <td>数据列表</td>
            </tr>
        </table>

        <h5>rows数组中的对象结构</h5>
        <table>
            <tr>
                <th>参数名</th>
                <th>类型</th>
                <th>描述</th>
            </tr>
            <tr>
                <td>id</td>
                <td>Long</td>
                <td>主键ID</td>
            </tr>
            <tr>
                <td>deviceId</td>
                <td>String</td>
                <td>设备ID/电表编号</td>
            </tr>
            <tr>
                <td>collectTime</td>
                <td>Date</td>
                <td>采集时间</td>
            </tr>
            <tr>
                <td>dcCurrent</td>
                <td>Float</td>
                <td>直流电流</td>
            </tr>
            <tr>
                <td>dcVoltage</td>
                <td>Float</td>
                <td>直流电压</td>
            </tr>
            <tr>
                <td>dcResistance</td>
                <td>Float</td>
                <td>直流炉阻</td>
            </tr>
            <tr>
                <td>activePower</td>
                <td>Float</td>
                <td>有功功率</td>
            </tr>
            <tr>
                <td>furnaceNo</td>
                <td>Integer</td>
                <td>炉号</td>
            </tr>
            <tr>
                <td>furnaceEnergy</td>
                <td>Integer</td>
                <td>单炉电量</td>
            </tr>
            <tr>
                <td>status</td>
                <td>Integer</td>
                <td>数据状态：1-正常，0-异常</td>
            </tr>
            <tr>
                <td>createTime</td>
                <td>Date</td>
                <td>创建时间</td>
            </tr>
            <tr>
                <td>createBy</td>
                <td>String</td>
                <td>创建者</td>
            </tr>
        </table>

        <h4>响应示例</h4>
        <div class="code-block">
{
    "code": 0,
    "msg": "查询成功",
    "total": 125,
    "rows": [
        {
            "id": 1,
            "deviceId": "YD001",
            "collectTime": "2024-05-20 10:30:00",
            "dcCurrent": 80.2,
            "dcVoltage": 220.5,
            "dcResistance": 2.75,
            "activePower": 125.5,
            "furnaceNo": 1,
            "furnaceEnergy": 500,
            "status": 1,
            "createTime": "2024-05-20 10:35:00",
            "createBy": "api"
        }
    ]
}
        </div>
    </div>

    <div class="section">
        <h2>3. 错误码说明</h2>
        <p>本API使用两套状态码系统：HTTP状态码和业务状态码。</p>
        
        <h3>3.1 HTTP状态码</h3>
        <p>HTTP状态码在HTTP协议层面返回，表示请求的处理结果：</p>
        <table>
            <tr>
                <th>错误码</th>
                <th>描述</th>
            </tr>
            <tr>
                <td>200</td>
                <td>操作成功</td>
            </tr>
            <tr>
                <td>500</td>
                <td>系统错误</td>
            </tr>
            <tr>
                <td>401</td>
                <td>未授权，Token无效或已过期</td>
            </tr>
            <tr>
                <td>400</td>
                <td>请求参数错误</td>
            </tr>
        </table>
        
        <h3>3.2 业务状态码</h3>
        <p>业务状态码在响应体的JSON数据中通过code字段返回，表示具体的业务处理结果：</p>
        <table>
            <tr>
                <th>错误码</th>
                <th>描述</th>
            </tr>
            <tr>
                <td>0</td>
                <td>操作成功</td>
            </tr>
            <tr>
                <td>500</td>
                <td>系统错误</td>
            </tr>
            <tr>
                <td>401</td>
                <td>未授权，Token无效或已过期</td>
            </tr>
            <tr>
                <td>400</td>
                <td>请求参数错误</td>
            </tr>
        </table>
        
        
    </div>

    <div class="section">
        <h2>4. 注意事项</h2>
        <ul>
            <li>日期格式支持两种形式：
                <ul>
                    <li>仅日期：yyyy-MM-dd (如：2024-05-20)</li>
                    <li>日期时间：yyyy-MM-dd HH:mm:ss (如：2024-05-20 10:30:00)</li>
                </ul>
            </li>
            <li>当使用仅日期格式时，系统会自动处理：
                <ul>
                    <li>开始日期会自动添加时间部分为00:00:00</li>
                    <li>结束日期会自动添加时间部分为23:59:59</li>
                </ul>
            </li>
            <li>分页查询接口至少需要提供一个查询条件（炉号或日期范围）</li>
        </ul>
    </div>
</body>
</html>